home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UPrefsDatabase.h < prev    next >
Encoding:
Text File  |  1994-02-20  |  3.6 KB  |  108 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UPrefsDatabase.h
  3.  
  4. #define __UPREFSDATABASE__
  5.  
  6. #ifndef __UPTROBJECT__
  7. #include "UPtrObject.h"
  8. #endif
  9.  
  10. class PDynDynArray;
  11.  
  12. class PPrefsDatabase : public PPtrObject
  13. {
  14.     public:
  15.         //----------------------------------------------
  16.         void GetPrefs(OSType id, void *data);
  17.         void SetPrefs(OSType id, const void *data, long size);
  18.         // warning: size is rounded to long-even-size
  19.         // nil means set only size
  20.  
  21.         long        GetPrefsSize                (OSType id);
  22.         void        DeletePrefs                    (OSType id); // no fail if not found
  23.         Boolean PrefExists                    (OSType id);
  24.         
  25.         Boolean    GetBooleanPrefs            (OSType id);
  26.         void        SetBooleanPrefs            (OSType id, Boolean b);
  27.  
  28.         short        GetShortPrefs                (OSType id);
  29.         void        SetShortPrefs                (OSType id, short i);
  30.  
  31.         long        GetLongPrefs                (OSType id);
  32.         void        SetLongPrefs                (OSType id, long l);
  33.  
  34.         void        GetVPointPrefs            (OSType id, VPoint &vp);
  35.         void        SetVPointPrefs            (OSType id, const VPoint &const vp);
  36.  
  37.         void        GetVRectPrefs                (OSType id, VRect &vr);
  38.         void        SetVRectPrefs                (OSType id, const VRect &const vr);
  39.         void        GetSilentVRectPrefs    (OSType id, VRect &vr); // 0 when new
  40.         
  41.         void        GetTextStylePrefs        (OSType id, TextStyle &theTextStyle);
  42.         void        SetTextStylePrefs        (OSType id, const TextStyle &theTextStyle);
  43.         
  44.         OSType    GetSignaturePrefs        (OSType id);
  45.         void        SetSignaturePrefs        (OSType id, const OSType signature);
  46.  
  47.         void        GetStringPrefs            (OSType id, CStr255 &prefs);
  48.         void        SetStringPrefs            (OSType id, const CStr255 &prefs);
  49.         void        SetStringPrefs            (OSType id, const char *prefs);
  50.  
  51.         Handle    GetHandlePrefs            (OSType id); // returns created handle, caller owns it
  52.         void        SetHandlePrefs            (OSType id, Handle h); // makes copy of handle contents
  53.  
  54.         Ptr            GetPtrPrefs                    (OSType id); // returns created ptr, caller owns it
  55.         void        SetPtrPrefs                    (OSType id, Ptr p); // makes copy of ptr contents
  56.  
  57.         // general alias
  58.         AliasHandle
  59.                         GetAliasHandlePrefs    (OSType id);
  60.         void        SetAliasHandlePrefs    (OSType id, AliasHandle ah);
  61.         //- specific for file aliases
  62.         void        GetAliasPrefs                (OSType id, FSSpec &spec);
  63.         Boolean    TryGetAliasPrefs        (OSType id, FSSpec &spec); // fail -> return false
  64.         void        SetAliasPrefs                (OSType id, const FSSpec &const spec);
  65.         //- specific for directory alises
  66.         void        GetDirAliasPrefs        (OSType id, FSSpec &spec); // name unused
  67.         void        SetDirAliasPrefs        (OSType id, const FSSpec &const spec);
  68.         void        GetSilentDirAliasPrefs(OSType id, FSSpec &spec, const OSType folderType = 'desk'); // desktop folder
  69.         // if could not find folder, changes prefs to 'folderType' (FolderMgr)
  70.     
  71.         void        SetWindowPosPrefs        (OSType id, TWindow *window);
  72.         void        GetSilentWindowPosPrefs(OSType id, TWindow *window);
  73.         
  74.         void        SetApplNameAndID        (OSType id, OSType applID, const CStr255 &name);
  75.         void        GetApplNameAndID        (OSType id, OSType &applID, CStr255 &name);
  76.  
  77.         //----------------------------------------------
  78.         virtual void DeleteAll();
  79.         virtual Boolean IsDirty();
  80.         
  81.         virtual void DoRead(TStream *aStream);
  82.         virtual void DoWrite(TStream *aStream);
  83.         virtual long NeededDiskSpace();
  84.  
  85.         void DumpPrefs(); // only available in qDebug
  86.         
  87.         PPrefsDatabase();
  88.         void IPrefsDatabase();
  89.         virtual ~PPrefsDatabase();
  90.     protected:
  91.         PDynDynArray *fPrefsDB;
  92.         TLongintList *fPrefsTypes;
  93.         Boolean fPrefsIsValid;
  94.         Boolean fIsDirty;
  95.  
  96.         long FindIndex(OSType id, Boolean failIfMissing = true); // kEmptyIndex when not found
  97.         Ptr ComputePrefsAddress(OSType id);
  98.         inline long RoundSize(long size);
  99.  
  100.         void SetDirtyFlag();
  101.         
  102.         inline void DebugCheckSize(OSType id, long size);
  103.         void ReportWrongSize(OSType id, long size);
  104.         void DumpTable();
  105. };
  106.  
  107. extern PPrefsDatabase *gPrefs;
  108.